/**
 * Created with JetBrains WebStorm.
 * User: ishowshao
 * Date: 13-5-9
 */
var Observable = require('events').EventEmitter;
var User = function (config) {
    this._id = config.id;
    this._name = config.name;
    this._lastAccess = new Date();
};
User.prototype = Object.create(Observable.prototype);
User.prototype.getId = function () {
    return this._id;
};
User.prototype.getName = function () {
    return this._name;
};
User.prototype.alive = function () {
    this._lastAccess = new Date();
};
User.prototype.isAlive = function () {
    var alive = true;
    var now = new Date();
    if (now - this._lastAccess > 21 * 1000) {
        alive = false;
    }
    return alive;
};

module.exports = User;
